package address

import (
	"api/internal/respons"
	"api/internal/svc"
	"api/internal/types"
	"context"
	"go.uber.org/zap"
	"smart-health-platforms/pkg"
	"user_srv/user"

	"github.com/zeromicro/go-zero/core/logx"
)

type AddressListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewAddressListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *AddressListLogic {
	return &AddressListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

// 地址列表
func (l *AddressListLogic) AddressList(req *types.AddressListRequest) (resp *types.Response, err error) {
	add, err := l.svcCtx.UserRpc.AddressList(l.ctx, &user.AddressListRequest{
		UserId: req.UserId,
	})
	if err != nil {
		pkg.Error("展示失败", zap.Error(err))
		return nil, err
	}
	return respons.Success(add), nil
}
